<%@page pageEncoding="UTF-8" isELIgnored="false" session="false"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@taglib prefix="f" uri="http://www.slim3.org/functions"%>
<%@ page import="java.util.*" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="calvin.controller.view.ChartController" %>
<%@ page import="calvin.datastore.model.Rate" %>
<%@ page import="calvin.datastore.model.Rate1h" %>
<jsp:useBean id="result" scope="request" class="java.util.ArrayList" />
<jsp:useBean id="cp" scope="request" class="java.lang.String" />
<jsp:useBean id="type" scope="request" class="java.lang.String" />
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>view Chart</title>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">
      google.load("visualization", "1", {packages:["corechart"]});
      google.setOnLoadCallback(drawChart);
      function drawChart() {
        var array = new Array();
        <% 
        for (Object o : result) {
        	Map<String, Object> m = (Map<String, Object>)o;
        	SimpleDateFormat sdf = new SimpleDateFormat("MM/dd HH:mm");
        	sdf.setTimeZone(TimeZone.getTimeZone("Asia/Tokyo"));
        	String time = sdf.format(m.get("t"));
        %>
            array.push(['<%=time%>',<%=m.get("l")%>,<%=m.get("o")%>,<%=m.get("c")%>,<%=m.get("h")%>]);
        <% } %>
        var data = google.visualization.arrayToDataTable(array, true);

        var options = {
        		candlestick: {
        			fallingColor: {
        				fill: 'red', 
        				stroke:'red'
        			},
					risingColor: {
						fill: 'green', 
						stroke:'green'
					}
        		},
    			hAxis: {
    				textStyle: {
    					color: 'black',
    					fontSize: 10
    				}
    			},
                legend:'none'
              };

        var chart = new google.visualization.CandlestickChart(document.getElementById('chart_div'));
        chart.draw(data, options);
      }
    </script>
  </head>
</head>
<body>
<div id="chart_div" style="width: 1200px; height: 600px;"></div>
</body>
</html>
